/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package BUS;

import DAO.TacGiaDAO;
import Entity.TacGia;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Dark_Knight
 */
public class TacGiaImpl implements TacGiaBUS {

    private TacGiaDAO dao;
    
    public TacGiaImpl() {
        dao = new DAO.TacGiaImpl();
    }
    
    public ArrayList getTacGia() {
        
        ResultSet rs = dao.getAll();
        
        ArrayList list = new ArrayList();
        TacGia data;
        
        try {
            while(rs.next()) {
                data = new TacGia(rs.getInt(1), rs.getString(2), true, null, null,
                        null, null);
                list.add(data);
            }         
        } catch (SQLException ex) {
            Logger.getLogger(DAO.TacGiaImpl.class.getName()).log(Level.SEVERE, null, ex);
        }
        return list;
    }

    public boolean add(TacGia data) {
        if (data.getTenTacGia().isEmpty())
            return false;
        
        return dao.add(data);
    }
    
}
